﻿using System.ComponentModel;
using AMatysiak.Converters;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Windows.Forms;

namespace AMatysiakTest.Converters
{
    [TestClass]
    public class PolishBooleanConverterTest
    {
        private class Money
        {
            private bool active;
            [TypeConverter(typeof(PolishBooleanConverter))]
            public bool Active
            {
                get { return active; }
                set { active = value; }
            }
        }

        [TestMethod]
        public void TestConverter()
        {
            Money money = new Money();
            money.Active = true;

            PropertyGrid grid = new PropertyGrid();
            grid.SelectedObject = money;
            GridItem item = grid.SelectedGridItem;
            PropertyDescriptor pd = item.PropertyDescriptor;
            TypeConverter conv = pd.Converter;
            string active = conv.ConvertTo(money.Active, typeof(string)).ToString();

            Assert.AreEqual("Tak", active);
        }
    }
}